package PTA.javaB;

import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Random;

public class ex11{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> List1 =new ArrayList<>();
        int n=sc.nextInt();
        int seed=sc.nextInt();
        int min=sc.nextInt();
        int max=sc.nextInt();
        int sum=0;
        Random  random= new Random(seed);//种子数

        for(int i=0;i<n;i++)
        {
            List1.add(min+random.nextInt(max));//范围[min,max)
        }

        int len=List1.size();
        for(int j= len-10;j<len;j++)
        {
            System.out.print(List1.get(j)+" ");
            sum+=List1.get(j);
        }
        System.out.println();
        System.out.println(sum);

        //报错 String[] str =List1.toArray(new String[0]);//注意：将列表中的元素添加到数组中；

        int str[]=new int[List1.size()];
        for(int i=0,j=List1.size();i<j;i++){
            str[i]=List1.get(i);
        }
        StringBuilder str2 = new StringBuilder();
        for(int k= len-10;k<len;k++)
        {
            str2.append(str[k]);
        }
        System.out.println(str2);

        int[] s =new int[10];
        int i=0;
        for(int j= len-10;j<len;j++)
        {
            s[i]=List1.get(j);
            i++;
        }

        Arrays.sort(s);
        System.out.println(Arrays.toString(s));

    }

}
